/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.model.service;

import com.model.domain.ubicacion.CentroPoblado;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;


/**
 *
 * @author Rdelacruz
 */
public class CentroPobladoService 
extends AbstractService
{

    public List<CentroPoblado> findByConglomerado(Connection con, String codigo) throws SQLException {
        List<CentroPoblado> lista = new ArrayList<CentroPoblado>();
        
        Statement st = null;
        try {                        
            st = con.createStatement();
            
            String sql = "select * from Campo_Centro_Poblado where conglome='"+codigo+"'";
            ResultSet rs = st.executeQuery(sql);            
            while(rs.next()) {
                CentroPoblado obj = new CentroPoblado();
                obj.setCodigo(rs.getString("codccpp"));
                obj.setNombre(rs.getString("nomccpp"));
                obj.setnViviendasSeleccionadas(rs.getInt("totviv"));
                
                lista.add(obj);
            }
        }
        finally {
            if(st!=null) st.close();
        }
        return lista;
    }
    
    
}
